Added to_i cast fixing String to number comparison error

Marcin Szymanski 10 lat temu
rodzic
commit
68437b9e0a
1 zmienionych plików z 2 dodań i 2 usunięć
  1. 2 2
      db/migrate/20131223032112_switch_to_json_serialization.rb

+ 2 - 2
db/migrate/20131223032112_switch_to_json_serialization.rb

@@ -37,8 +37,8 @@ class SwitchToJsonSerialization < ActiveRecord::Migration
37 37
   end
38 38
 
39 39
   def data_exists?
40
-    events = ActiveRecord::Base.connection.select_rows("SELECT count(*) FROM #{ActiveRecord::Base.connection.quote_table_name("events")}").first.first
41
-    agents = ActiveRecord::Base.connection.select_rows("SELECT count(*) FROM #{ActiveRecord::Base.connection.quote_table_name("agents")}").first.first
40
+    events = ActiveRecord::Base.connection.select_rows("SELECT count(*) FROM #{ActiveRecord::Base.connection.quote_table_name("events")}").first.first.to_i
41
+    agents = ActiveRecord::Base.connection.select_rows("SELECT count(*) FROM #{ActiveRecord::Base.connection.quote_table_name("agents")}").first.first.to_i
42 42
     agents + events > 0
43 43
   end
44 44